<template>
	<view class="" v-if="!userInfo" style="width: 100vw; height: 100vh;" >
		<image src="/static/img/WechatIMG159.png" style="width: 100%; height: 100%;" mode=""></image>
	</view>
	<view class="activityDetails" v-else>
		<!-- 图片轮播 -->
		<view class="swiper">
			<u-swiper :list="dataObj.images" height="750"></u-swiper>
		</view>
		<view style="position: relative; width: 100%; height: 72rpx; margin-top: 25rpx;"
			v-if="dataObj.estimate_price != undefined">
			<view
				style="width: 100%; height: 100%; background: linear-gradient(180deg, #FEF9F1 0%, #EABE70 100%); box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.1); border-radius: 0px 0px 6px 6px; font-size: 24rpx; font-weight: 500; opacity: 0.1;">
			</view>
			<image
				style="position: absolute; top: 50%; left: 20rpx; transform: translateY(-50%); width: 36rpx; height: 36rpx; opacity: 1;"
				src="/static/icon/icon-sy@3x.png" mode="widthFix"></image>
			<view
				style="position: absolute; top: 50%; left: 66rpx; transform: translateY(-50%); color: #EEC379; opacity: 1;">
				预计收益{{dataObj.estimate_price}}元</view>
		</view>
		<!-- 产品 -->
		<view class="product">
			<!-- 价格 -->
			<view class="content_t flex-r-b-c">
				<view class="content_t_l flex-r-s-c">
					<view class="price">¥<text>{{dataObj.price}}</text></view>
					<view class="original" v-if=" dataObj.orginal_price != 0 ">原价 <view class="price">
							¥<text>{{dataObj.orginal_price}}</text></view>
					</view>
					<view class="collage" v-if="pageData.type==3">拼团价 ¥<text>{{dataObj.activity.price}}</text></view>
					<view class="collage" v-if="pageData.type==2">秒杀价 ¥<text>{{dataObj.activity.price}}</text></view>
					<view class="collage" v-if="pageData.type==1 && pageData.activity_id">活动价
						¥<text>{{dataObj.activity.price}}</text></view>
				</view>
				<!-- <view class="content_t_f">服务时间约为{{dataObj.sminute}}分钟</view> -->
			</view>
			<!-- 介绍 -->
			<view class="content_b">
				<view class="name">{{dataObj.name}}</view>
				<view class="introduce">{{dataObj.describe == null ? '' : dataObj.describe}}</view>
			</view>
		</view>
		<!-- 购买数量 -->
		<view class="quantity flex-r-b-c" v-if="dataObj.spe.length == 0">
			<view class="text">购买数量</view>
			<view class="quantity_f flex-r-s-c">
				<!-- <view class="reduce btn" @click="AddGood_inp>1?AddGood_inp--:''">-</view>
				<input disabled type="number" :value="AddGood_inp" />
				<view class="plus btn" @click="AddGood_inp++">+</view> -->
				<view class="reduce btn" @click="reduce">-</view>
				<input disabled type="number" :value="AddGood_inp" />
				<view class="plus btn" @click="add">+</view>
			</view>
		</view>
		<!-- 拼团 -->
		<view class="collageBox" v-if="pageData.type==3">
			<view class="content_t flex-r-b-c">
				<view class="text">{{dataObj.activity.size}}人在拼团，可直接参与</view>
				<view class="more" @tap="isCollageList = true">查看更多 <u-icon name="arrow-right" color="#ACACAC"
						size="20"></u-icon>
				</view>
			</view>
			<!-- 拼单列表 -->

			<view class="list flex-r-b-c" v-for="(item,index) in collageList.slice(0,4)" :key="index">
				<view class="list_l flex-r-s-c">
					<image :src="item.userimg" mode=""></image>
					<view class="name">{{item.nickname}}</view>
				</view>
				<view class="list_f flex-r-s-c">
					<view class="list_f_l">
						<view class="title">还差<text>{{item.num}}人</text>拼成</view>
						<view class="time">剩余{{item.end_time}}</view>
					</view>
					<view class="collageBtn"
						@click="Goods_inStock({activity_id: pageData.activity_id,activity_num:1,group_team: item.group_team, isone: pageData.isone})">
						去拼团</view>
				</view>
			</view>

		</view>
		<!-- 用户评价 -->
		<view class="userEvaluate">
			<view class="title flex-r-b-c">
				<view class="name">用户评价（{{count}}条）</view>
				<view class="whole" v-if="count>1" @click="isComment_fn">查看全部</view>
				<view class="" v-else></view>
			</view>
			<!-- 列表 -->
			<view class="list" v-for="(v,i) in commentList.slice(0,1)" :key="i">
				<!-- 用户信息 -->
				<view class="userInfo flex-r-b-c">
					<view class="userInfo_l flex-r-s-c">
						<u-avatar :src="v.userimg" size="60"></u-avatar>
						<!-- <image :src="v.userimg" mode="aspectFill"></image> -->
						<view class="userInfo_l_r">
							<view class="name">{{v.nickname}}</view>
							<u-rate :current="v.good_score" active-color="#FF892A" :disabled="true"></u-rate>
						</view>
					</view>
					<view class="time">{{v.createdate}}</view>
				</view>
				<!-- 评价 -->
				<view class="evaluate">
					<view class="text">{{v.content}}</view>
					<view class="imageBox flex-r-s-c" v-if="v.images.length!=0">
						<image v-for="(imgs,i1) in v.images" :key="i1" :src="base.imgUrl+imgs" mode="aspectFill"
							@click="imgs_fn( v.images,i1)">
						</image>
					</view>
				</view>
			</view>
		</view>
		<!-- 图文详情 -->
		<view class="imageText">
			<view class="title">图文详情</view>
		</view>
		<u-parse :html="dataObj.content"></u-parse>
		<!-- <rich-text style="width: 100%;" :nodes="dataObj.content"></rich-text> -->
		<view style="height: 150rpx;width: 750rpx;"></view>
		<!-- 购物栏 -->
		<view class="bottomBtn flex-r-c-c">

			<!-- <view style="position: relative;" v-if="pageData.type == 1 && !pageData.activity_id">
				<image src="../../static/icon/shoping.png" mode="" v-if="pageData.type == 1 && !pageData.activity_id"
					@tap.stop="getCartList(true)">
				</image>
				<view class="redDot" v-if="shopRedDotNum > 0">{{shopRedDotNum}}</view>
			</view> -->

			<view class="btnBox pt flex-r-a-c" v-if="pageData.type==3">
				<!-- <navigator class="purchase btn" url="">立即购买</navigator> -->
				<!-- <view class="collage btn" >发起拼团</view> -->
				<!-- <view class="shopCart btn" @tap="isLaunch = true">发起拼团</view> -->
				<button class="tipsBtn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
					v-if="dataObj.phone == null">发起拼团</button>
				<view class="tipsBtn" v-else @click="Goods_inStock({activity_id:pageData.activity_id,activity_num:1,isone: pageData.isone})">
					发起拼团</view>

			</view>

			<view class="tipsBtn" v-if="pageData.type == 2 && !isTipsBtn" @tap.stop="isRemind = true">
				{{dataObj.activity.start_time}}<text>提醒我</text>
			</view>

			<button class="tipsBtn" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
				v-if="pageData.type == 1 && pageData.activity_id && dataObj.phone == null || pageData.type == 2 && isTipsBtn && dataObj.phone == null">立即购买</button>

			<view class="tipsBtn" v-else-if="pageData.type == 2 && isTipsBtn"
				@click="Goods_inStock({activity_id:pageData.activity_id,activity_num:AddGood_inp,isone: pageData.isone})">
				立即购买</view>

			<view class="tipsBtn" v-else-if="pageData.type == 1 && pageData.activity_id"
				@click="Goods_inStock({activity_id:pageData.activity_id,activity_num:AddGood_inp,isone: pageData.isone})">
				立即购买</view>


			<view class="btnBox flex-r-s-c" v-if="pageData.type == 1 && !pageData.activity_id">
				<view class="immediately b" @click="ShopCarAddGood">加入购物车</view>
				<button class="join b" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
					v-if="dataObj.phone == null">立即购买</button>
				<view class="join b" v-else @click="Goods_inStock([{id:dataObj.id,num:AddGood_inp,isone: pageData.isone}])">
					立即购买</view>
			</view>

		</view>
		<!-- 购物车按钮 -->
		<view class="cart_box flex-r-b-c" v-if="isBtnDisplay">

			<view class="icon" v-if="isIconShow">
				<!-- <u-icon name="shopping-cart" color="#0F4C3A" size="60"></u-icon> -->
				<image style="width: 60rpx; height: 58rpx;" src="/static/icon/shoping.png" mode="widthFix">
				</image>
				<view class="redDot" v-if="shopRedDotNum > 0">{{shopRedDotNum}}</view>
			</view>
			<view v-else></view>
			<view class="paymentBtn" @tap.stop="paymentBtn">付款</view>

		</view>


		<view style="width: 100vw; height: 80rpx; background-color: #FFF; position: fixed; left: 0; bottom: 0;"></view>
		<!-- 发起拼团弹框 -->
		<!-- <u-popup v-model="isLaunch" mode="bottom" border-radius="20" height="700" closeable>
			<view class="launchPopup">
				<image class="image" src="../../static/mine/hdymimg.png" mode="widthFix"></image>
				<view class="activity">
					<view class="background">
						<view class="title">参与团长的拼团</view>
						<view class="text">仅剩1个名额，<text class="time">20:00:00</text>后结束</view>
						<view class="popupImageBox flex-r-a-c">
							<image v-for="(item,index) in popupImage.slice(0,5)" :key="index" :src="item" mode="">
							</image>
							<view v-if="popupImage.length > 5" class="personnel">20+</view>
						</view>
						<view class="btn">参与拼团</view>
					</view>
				</view>
			</view>
		</u-popup> -->


		<!-- 提醒我弹框 -->
		<u-popup v-model="isRemind" mode="center" width="90%" height="40%" border-radius="20">
			<view class="remindPopup popup">
				<image src="../../static/mine/txw.png" mode="widthFix"></image>
				<view class="text">秒杀前5分钟会提醒您</view>
				<view class="btn" @tap="newsRemind">确定</view>
			</view>
		</u-popup>



		<!-- 拼团列表弹框 -->
		<u-popup v-model="isCollageList" mode="bottom" border-radius="20" closeable>
			<view class="collageListPopup" style="margin-top: 80rpx;">
				<scroll-view scroll-y="true" @scrolltolower="collage" style="height: 800rpx;">
					<view class="list flex-r-b-c" v-for="(item,index) in collageList" :key="index">
						<view class="list_l flex-r-s-c">
							<image :src="item.userimg" mode=""></image>
							<view class="name">{{item.nickname}}</view>
						</view>
						<view class="list_f flex-r-s-c">
							<view class="list_f_l">
								<view class="title">还差<text>{{item.num}}人</text>拼成</view>
								<view class="time">剩余{{item.end_time}}</view>
							</view>
							<navigator class="collageBtn"
								@click="Goods_inStock({activity_id: pageData.activity_id,activity_num:1, group_team: item.group_team, isone: pageData.isone})">
								去拼团</navigator>
						</view>
					</view>

					<view class="text" style="width: 100%; text-align: center; font-size: 32rpx; font-weight: bold;">
						{{titleText}}
					</view>
				</scroll-view>
			</view>
		</u-popup>

		<!-- 多规格弹框 -->
		<u-popup v-model="isDGGShow" height="50vh" :closeable="true" :customStyle="{bottom:'114rpx'}" border-radius="14"
			mode="bottom" @close="DGGPopupDlose">
			<view style="padding: 30rpx;">
				<view class="name">已选服务</view>
				<scroll-view scroll-y="true" style="height: 50vh; margin-top: 40rpx;">

					<view class="popup_list flex-r-b-c" v-for="(item,index) in dataObj.spe" :key="index">
						<image :src="base.smallimgUrl + item.image" mode=""></image>
						<view class="popup_list_r">

							<view class="list_r_t flex-r-b-c">
								<view class="name">{{item.name}}</view>
								<view class="time" v-if="item.sminute != null">约{{item.sminute}}分钟</view>
							</view>

							<view class="list_r_b flex-r-b-c">
								<view class="popup_price">¥<text>{{item.price}}</text></view>

								<view class="popup_quantity flex-r-b-c">
									<view class="reduce text" style="box-sizing: border-box; padding: 16rpx;"
										@tap.stop="DGGdeleteCart(item.goods_id,item.id,item.num)" v-if="!isIconShow">-
									</view>
									<view class="reduce text" style="box-sizing: border-box; padding: 16rpx;"
										@tap.stop="deleteCart(item.goods_id,item.id,item.num)" v-else>-</view>
									<input type="number" disabled class="quantityNum" :value="item.num" />
									<view class="plus text" style="box-sizing: border-box; padding: 16rpx;"
										@tap.stop="DGGaddCart(item.goods_id,item.id,item.num)" v-if="!isIconShow">
										+</view>
									<view class="plus text" style="box-sizing: border-box; padding: 16rpx;"
										@tap.stop="addCart(item.goods_id,item.id,item.num)" v-else>
										+</view>
								</view>

							</view>
						</view>
					</view>
				</scroll-view>
			</view>
		</u-popup>

		<!-- 评论弹框 -->
		<u-popup v-model="isComment" mode="bottom" width="100%" :height="hei+50+'px'" border-radius="20">
			<view class="flex-c-c-c" style="width: 100%;height: 49px;border-bottom: 1px solid #F5F5F5;">
				用户评价（{{count}}条）
			</view>
			<scroll-view scroll-y="true" @scrolltolower='pinlun()' lower-threshold='50' :style="{height:hei+'px'}">
				<view class="userEvaluate">
					<!-- 列表 -->
					<view class="list" v-for="(v,i) in commentList" :key="i">
						<!-- 用户信息 -->
						<view class="userInfo flex-r-b-c">
							<view class="userInfo_l flex-r-s-c">
								<u-avatar :src="v.userimg" size="60"></u-avatar>
								<!-- <image :src="v.userimg" mode="aspectFill"></image> -->
								<view class="userInfo_l_r">
									<view class="name">{{v.nickname}}</view>
									<u-rate :current="v.good_score" active-color="#FF892A" :disabled="true"></u-rate>
								</view>
							</view>
							<view class="time">{{v.createdate}}</view>
						</view>
						<!-- 评价 -->
						<view class="evaluate">
							<view class="text">{{v.content}}</view>
							<view class="imageBox flex-r-s-c" v-if="v.images.length!=0">
								<image v-for="(imgs,i1) in v.images" :key="i1" :src="base.imgUrl+imgs" mode="aspectFill"
									@click="imgs_fn( v.images,i1)">
								</image>
							</view>
						</view>
					</view>
					<view class="flex-c-c-c" style="width: 100%;height: auto;">
						{{comment_list_text}}
					</view>
				</view>
			</scroll-view>
		</u-popup>
		<!-- 地址选择 -->
		<u-popup v-model="store_show" mode="bottom" border-radius="50" width="100vw" height="1030rpx" z-index='10000'
			:mask-close-able="userInfo?true:false">
			<view class="flex-r-b-c" style="width: 100%;height:110rpx;padding: 0px 16px;">
				<text style="color: #333333;font-size: 18px;font-weight: bold;" @click="store_fn()">选择门店</text>
				<!-- <text @click="userInfo?store_true():getUserInfo()" style="color: #333333;font-size: 15px;">确定</text> -->
			</view>
			<view style="width:100%;height:76rpx;margin-bottom: 24rpx;" class="flex-c-c-c">
				<view class="flex-r-b-c" style="width:686rpx;height:76rpx;">
					<view class="flex-r-s-c" style="width: 528rpx;height:76rpx;">
						<u-search style="width: 100%;" placeholder="请输入门店名称" :show-action="false"
							v-model="store_obj.seach"></u-search>
					</view>
					<view class="flex-c-c-c"
						style="width: 130rpx;height: 62rpx;border-radius:8rpx;background-color: #45806E;">
						<text style="font-size: 28rpx;color: #FFFFFF;" @click="store_list_fn()">搜索</text>
					</view>
				</view>
			</view>
			<scroll-view scroll-y="true" style="height:800rpx;" @scrolltolower='store_lists()' lower-threshold='50'>
				<view style="padding: 0px 6px;">
					<view class="flex-r-b-c" @tap.stop="store_true(v.id)"
						style="height:117px;width: 726rpx;border-color: #45806E;border-radius: 10px;border-style: solid;"
						v-for="(v,i) in store_list" :key='i' @click="store_active=i"
						:style="{borderWidth:store_active===i?'3rpx':'0px',padding:store_active===i?'0px 10px':'12px',boxShadow:store_active===i?'0px 3px 3px rgba(69, 128, 110, 0.22)':'none'}">
						<view class="flex-r-s-c" style="width:550rpx;">
							<view class="flex-c-c-c"
								style="width: 250rpx;height: 98px;box-shadow: 0px 3px 3px rgba(69, 128, 110, 0.22);border-radius: 6px;background-color: #FFFFFF;overflow: hidden;">
								<image :src="base.imgUrl+v.image" mode="widthFix"
									style="width: 250rpx;border-radius: 6px;">
								</image>
							</view>
							<view class="flex-c-b-s" style="height: 98px;margin-left: 30rpx;width: 250rpx;">
								<text class="one-line-ellipsis">{{v.name}}</text>
								<view class="flex-r-s-c">
									<image src="../../static/icon/store.png" mode="widthFix" style="width: 11px;">
									</image>
									<text style="color: #999999;font-size: 12px;margin-left: 5px;">{{v.area}}</text>
								</view>
								<view class="flex-r-s-c">
									<image src="../../static/icon/phone.png" mode="widthFix" style="width: 11px;">
									</image>
									<text style="color: #999999;font-size: 12px;margin-left: 5px;">{{v.mobile}}</text>
								</view>
								<text class="one-line-ellipsis"
									style="font-size: 12px;color: #5D5D5D;width: 100%;">{{v.address}}</text>
							</view>
						</view>
						<view class="flex-c-b-e" style="height: 98px;width: 150rpx;">
							<view class="flex-r-s-c">
								<image src="../../static/icon/position1.png" mode="widthFix" style="width: 9px;">
								</image>
								<text style="color: #0F4C3A;font-size: 12px;margin-left: 5px;">{{v.distance}}km</text>
							</view>
							<u-button type="success " @click.stop="store_details_jump(v.id)"
								:custom-style="{backgroundColor: '#45806E',height:' 30px',width: '65px',marginBottom:' 23px',fontSize:'14px'}">
								详 情</u-button>
						</view>
					</view>
				</view>
				<view class="flex-c-c-c" style="height: 50rpx;">
					<text>{{store_list_text}}</text>
				</view>
			</scroll-view>
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				base: this.$base,
				isRemind: false, // 提醒弹框
				isShow: false, // 购物车弹框
				pageData: {
					id: null,
					type: null,
					activity_id: null,
					store_id: null,
				}, //上级页面传递参数区分----->type:1-普通商品2-抢购商品3-拼团商品
				// isLaunch: false, //发起拼团弹框
				isCollageList: false, //查看更多列表弹框
				listImage: [ //swiper图片
					'',
					''
				],
				popupImage: [ /*拼团会员头像*/ ],
				dataObj: {}, //商品数据
				AddGood_inp: 1, //选择数量
				commentList: [], //评论列表
				isTipsBtn: null, // 是否是当前活动时间
				collageList: [], // 拼团列表
				cartList: [], // 购物车列表
				shopRedDotNum: 0, // 购物车数量提醒
				page: 1, // 页码
				titleText: '', // 上拉提示
				collageNum: 0, // 参与拼团人数
				userInfo: uni.getStorageSync('user_info'), // 用户登录信息
				isComment: false, //是否弹出评论弹框
				comment_obj: { //评论对象
					goods_id: null,
					page: 0,
					num: 10
				},
				comment_list_text: '', //评论下拉文字
				count: 0, //评论数量
				hei: this.$hei - 100,
				isBtnDisplay: false, // 购物车栏显示
				isDGGShow: false, // 多规格弹框显示
				isIconShow: null,
				store_show: !uni.getStorageSync('store_dz'), //门店弹框显示否
				store_obj: { //门店列表
					num: 10,
					page: 0 //请求页数
				},
				store_list: [],
				store_keyword: '', //门店搜索框
				store_active: 0, //门店或搜索后的选择门店下标
				store_list_text: '加载更多....', //门店列表加载提示
			};
		},
		onLoad(el) {
			console.log('进入页面获得的参数', el)
			if (el?.scene) {
				let els = el.scene.split(',')
				els[1] == 1 && els[2] == 0 ? el = {
					id: els[0],
					type: els[1],
					userID: els[3]
				} : el = {
					id: els[0],
					type: els[1],
					activity_id: els[2],
					userID: els[3]
				}
				console.log(el)
			}
			this.pageData = el
			this.isComment = el?.isComment ? true : false
			this.comment_obj.goods_id = el.id
			if (el?.type == 3) {
				this.getCollageList()
			}
			if(el?.store_dz){
				let store_dz = JSON.parse(el.store_dz)
				uni.setStorageSync('store_dz',store_dz)
				this.saveUsetStore()
				this.store_show = false
			}
			if (el?.userID != undefined) { //绑定用户上级
				// this.$api.User_savePid({
				// 	id: el.userID,
				// 	goods_id: el.id
				// })
				uni.setStorageSync('scene_id',el.userID)
			}
			if (!uni.getStorageSync('store_dz')) {
				console.log('获取当前定位')
				this.store_fn()
			}
			// if (el.type == 1) { //普通商品---买一赠一   activity_id存在买一赠一否则普通
			// 	if (el?.activity_id) {//买一赠一

			// 	}else{//普通

			// 	}
			// } else if (el.type == 2) { //秒杀

			// } else if (el.type == 3) { //拼团

			// }
			console.log('进入页面获得的参数', this.pageData)
		},
		onShow() {
			this.pinlun()
			this.goods_getContents()
			
			if (uni.getStorageSync('store_dz')) {
				
				this.getCartList(false)
			} else {
				
				this.store_fn()
			}
			// if (this.pageData.type == 1) { //普通商品
			// } else if (this.pageData.type == 2) { //抢购商品
			// } else if (this.pageData.type == 3) { //拼单商品
			// }
		},
		// #ifdef MP-WEIXIN
			onShareTimeline() { // 分享朋友圈
				const storeName = uni.getStorageSync('store_dz').name;
				let data = ""
				console.log(this.userInfo,'用户信息')
				console.log(this.userInfo.id,'用户id')
				if(this.pageData.activity_id){
					data = `id=${this.pageData.id}&type=${this.pageData.type}&activity_id=${this.pageData.activity_id}&userID=${JSON.stringify(this.userInfo.id)}&store_dz=${JSON.stringify(uni.getStorageSync('store_dz'))}`
				} else {
					data = `id=${this.pageData.id}&type=${this.pageData.type}&userID=${JSON.stringify(this.userInfo.id)}&store_dz=${JSON.stringify(uni.getStorageSync('store_dz'))}`
				}
				let path = `/order/activityDetails/activityDetails`
				console.log(path)
				return {
					title: storeName + this.dataObj.name,
					path: path,
					query: data,
					imageUrl: this.base.imgUrl + this.dataObj.image,
					success(res){
						console.log(res,'分享朋友圈')
						uni.showToast({
							title: '分享成功'
						})
					},
					fail(err){
						console.log(err)
						uni.showToast({
							title: '分享失败',
							icon: 'none'
						})
					}
				}
			},
		// #endif

		onShareAppMessage() {
			console.log(this.userInfo.id, '查看分享人的id' )
			this.pageData.store_id = uni.getStorageSync('store_dz').id;
			const storeName = uni.getStorageSync('store_dz').name;
			let path = `/order/activityDetails/activityDetails${this.get_fn(this.pageData)}&userID=${this.userInfo.id}}`
			return {
				title: storeName + this.dataObj.name,
				path: path,
				imageUrl: this.base.imgUrl + this.dataObj.image,
				// desc: this.dataObj.,
				content: this.dataObj.describe,
				success(res) {
					uni.showToast({
						title: '分享成功'
					})
				},
				fail(err) {
					uni.showToast({
						title: '分享失败',
						icon: 'none'
					})
					console.log(res)
				}
			}
		},
		// 监听
		watch: {
			// 监听数量
			AddGood_inp(el) {
				let that = this
				if (that.pageData.type == 2 || that.pageData.type == 1 && that.pageData.activity_id) {
					if (el >= that.dataObj.activity.num) {
						that.AddGood_inp = that.dataObj.activity.num
						uni.showToast({
							title: '已经到了该活动商品的购买上限',
							icon: 'none'
						})
					}
				} else if (that.pageData.type == 3) {
					that.AddGood_inp = 1
					uni.showToast({
						title: '拼团一次只能购买一次',
						icon: 'none'
					})
				}
			}
		},
		methods: {
			reduce() {//购物数量减少
				this.AddGood_inp > 1 ? this.AddGood_inp-- : ''
			},
			add() {//购物数量增加
				this.AddGood_inp++
			},
			goods_getContents() {
				this.$api.goods_getContent({
					id: this.pageData.id, //this.pageData.id
					activity_id: this.pageData?.activity_id,
					store_id: this.pageData?.store_id
				}).then(res => {
					console.log('goods_getContent', res)
					res.data.data.images = res.data.data.images.map((value, index, array) => {
						return this.$base.imgUrl + value
					})
					this.dataObj = res.data.data
					let currentTime = new Date().getTime()
					let startTime = null
					if (uni.getSystemInfoSync().platform == 'ios') {
						startTime = new Date(res.data.data.activity.start_time.replace(/-/g, '/')).getTime()
					} else {
						startTime = new Date(res.data.data.activity.start_time).getTime()
					}
					currentTime > startTime ? this.isTipsBtn = true : this.isTipsBtn = false
				})
			},
			store_true(id) { //门店弹框收起
				let that = this
				that.store_list.map(el => {
					if (el.id == id) {
						uni.setStorageSync('store_dz', el)
					}
				});
				!uni.getStorageSync('user_info') ? uni.navigateTo({
					url: '/mine/login/login'
				}) : that.saveUsetStore();
				that.store_show = false
				// uni.setStorage({
				// 	key: 'store_dz',
				// 	data: that.store_list[that.store_active],
				// 	success: function() {}
				// });
			},
			saveUsetStore() {
				let that = this
				that.$api.store_saveUsetStore({
					store_id: uni.getStorageSync('store_dz').id
				}).then(res => {
					console.log(res)
				})
			},
			store_details_jump(id) {
				uni.navigateTo({
					url: `/store/Storedetails/Storedetails?id=${id}`
				})
			},
			store_lists() { //门店列表
				let that = this
				if (that.store_list_text == '无更多门店') return
				that.store_list_text = that.store_list.length == 0 ? '暂无门店' : '加载中...'
				that.store_obj.page++
				that.$api.store_list(that.store_obj).then(res => {
					that.store_list_text = res.data.data.length == 0 || res.data.data.length < 10 ? '无更多门店' :
						'加载更多...'
					res.data.data.length == 0 ? '' : that.store_list = that.store_list.concat(res.data.data)
				})
			},
			store_list_fn() { //门店搜索
				this.store_list = [];
				this.store_list_text = '加载中...'
				this.store_obj.page = 0;
				this.store_lists()
			},
			store_fn() { //获取当前位置
				var that = this
				uni.getLocation({
					type: 'wgs84',
					success(res) {
						that.store_obj.lng = res.longitude //当前位置的经度
						that.store_obj.lat = res.latitude //当前位置的纬度
						that.store_obj.page = 0
						that.store_list = []
						that.store_list_text = '加载更多....'
						that.store_lists()
						uni.setStorage({
							key: 'store',
							data: {
								lng: res.longitude,
								lat: res.latitude
							},
							success: function() {}
						});
					}
				});
			},
			Goods_inStock(obj) {
				let that = this
				if (that.dataObj.activity.num == 0) {
					uni.showToast({
						title: "该商品已达到购买上限",
						icon: "none"
					})
				} else {
					this.$api.Goods_inStock({
						goods_id: this.pageData.id,
						id: this.pageData.activity_id
					}).then(res => {
						console.log(obj)
						console.log(that.dataObj)
						if (that.dataObj.spe.length == 0) {
							uni.navigateTo({
								url: '/order/orderConfirm/orderConfirm?goods=' + encodeURIComponent(JSON
									.stringify(
										obj))
							})
						} else {
							that.isBtnDisplay = true
							that.isDGGShow = true
							that.isIconShow = false
						}
					})
				}

			},
			DGGPopupDlose() { // 多规格弹框关闭
				this.isBtnDisplay = false
				this.isDGGShow = false
				this.isIconShow = null
				this.dataObj.spe.filter(e => {
					e.num = 0
				})
			},
			paymentBtn() { // 去支付
				let that = this
				var obj = []
				if (!that.isIconShow) {
					that.dataObj.spe.map(e => {
						if (e.num > 0) {
							let data = {
								id: e.goods_id,
								num: e.num,
								spe_id: e.id,
							}
							obj = obj.concat(data)
						}
					})
					uni.navigateTo({
						url: '/order/orderConfirm/orderConfirm?goods=' + encodeURIComponent(JSON
							.stringify(
								obj))
					})
				} else {
					that.cartList.forEach(e => {
						obj.push({
							id: e.id,
							num: e.num,
							spe_id: e.spe_id
						})
					})
					uni.navigateTo({
						url: '/order/orderConfirm/orderConfirm?goods=' + encodeURIComponent(JSON.stringify(obj))
					})
				}
			},
			isComment_fn() {
				this.isComment = true
			},
			get_fn(data) {
				var arr = Object.keys(data);
				var str = "?";
				for (var i in data) {
					str += i;
					str += "=";
					str += data[i];
					str += "&";
				}
				return str.substr(0, str.length - 1)
			},
			getCollageList() { // 拼团列表
				let that = this
				that.$api.collage_list({
					id: that.pageData.activity_id,
					page: that.page
				}).then(res => {
					console.log(res)
					that.titleText = res.data.data.order.length == 0 ? '暂无数据' : ''
					that.collageList = that.collageList.concat(res.data.data.order)
				})
			},
			collage() { // 拼团列表下拉
				let that = this
				if (that.titleText == '') { // 防止上拉多次请求
					that.page = that.page + 1
					that.getCollageList()
				}
			},
			pinlun() { //评论列表
				// that.$api.UserComment_commentList(that.comment_obj).then(res => {
				// 	that.commentList = res.data.data 
				// })
				let that = this
				if (that.comment_list_text == '无更多评论') return
				that.comment_list_text = that.commentList.length == 0 ? '暂无评论' : '加载中...'
				that.comment_obj.page++
				that.$api.UserComment_commentList(that.comment_obj).then(res => {
					that.count = res.data.data.count
					that.comment_list_text = res.data.data.list.length == 0 || res.data.data.list.length < 10 ?
						'无更多评论' :
						'加载更多...'
					res.data.data.list.length == 0 ? '' : that.commentList = that.commentList.concat(res.data.data
						.list)
				})
			},
			ShopCarAddGood() { //加入购物车
				let that = this
				if (that.dataObj.spe.length == 0) {
					this.$api.ShopCar_addGood({
						id: this.dataObj.id,
						num: this.AddGood_inp,
						type: 1
					}).then(res => {
						uni.showToast({
							title: "添加成功",
							icon: "none"
						})
						this.getCartList(false)
					})
				} else {
					that.isBtnDisplay = true
					that.isDGGShow = true
					that.isIconShow = true
				}
			},
			imgs_fn(arr, i) { //图片预览
				arr = arr.map((value, index, array) => {
					return this.$base.imgUrl + value

				})
				console.log(arr)
				uni.previewImage({
					current: i,
					urls: arr,
				});
			},
			getPhoneNumber(e) { // 获取手机号
				console.log(e)
				let that = this
				var data = {}
				uni.checkSession({
					success(res) {
						console.log(res)
						if (res.errMsg == 'checkSession:ok') {
							data = {
								sessionKey: uni.getStorageSync('user_info').data.sessionKey,
								encryptedData: e.detail.encryptedData,
								iv: e.detail.iv
							}
							that.$api.getPhone(data).then(res => {
								console.log(res)
								that.dataObj.phone = res.data
								uni.showToast({
									title: '手机号已获取，请再次点击购买',
									icon: 'none'
								})
							})
						} else {
							uni.login({
								success(res) {
									data = {
										code: res.code,
										encryptedData: e.detail.encryptedData,
										iv: e.detail.iv
									}
									that.$api.getPhone(data).then(res => {
										console.log(res)
										that.dataObj.phone = res.data
										uni.showToast({
											title: '手机号已获取，请再次点击购买',
											icon: 'none'
										})
									})
								}
							})
						}
					}
				})
			},
			// 点击消息提醒
			newsRemind() {
				let that = this
				that.$api.news_remind({
					activity_id: that.pageData.activity_id
				}).then(res => {
					console.log(res)
					uni.showToast({
						title: '设置成功',
						icon: 'none'
					})
					that.isRemind = false
				})
			},
			// 点击获取购物车列表
			getCartList(el) {
				let that = this
				that.isShow = el
				that.$api.cart_list().then(res => {
					console.log(res)
					that.cartList = res.data.data
					var num = 0
					res.data.data.map(e => num += e.num)
					that.shopRedDotNum = num
				})
			},
			DGGdeleteCart(goodID, id, num) {
				let that = this
				that.dataObj.spe.filter(e => {
					if (e.id == id) {
						e.num == 0 ? e.num = 0 : e.num--
					}
				})
			},
			DGGaddCart(goodID, id, num) {
				let that = this
				that.dataObj.spe.filter(e => {
					if (e.id == id) {
						e.num++
					}
				})
			},
			// 购物车中的 添加
			addCart(goodID, id, num) {
				let that = this
				that.dataObj.spe.filter(e => {
					if (e.id == id) {
						e.num++
					}
				})
				that.getAdd(goodID, id)
			},
			// 购物车中的 删除
			deleteCart(goodID, id, num) {
				console.log(num)
				let that = this
				let is = null
				that.dataObj.spe.filter(e => {
					if (e.id == id) {
						e.num == 0 ? e.num = 0 : e.num--
					}
				})
				num == 0 ? is = true : is = false
				num--
				that.getAdd(goodID, id, num, is)
			},
			// 添加的方法
			getAdd(goodID, id, num, is) {
				this.$api.add_cart({
					id: goodID,
					spe_id: id,
					num: Number(num)
				}).then(res => {
					if (num) {
						uni.showToast({
							title: '删除成功',
							icon: 'none'
						})
						this.getCartList(true)
					} else if (is) {
						uni.showToast({
							title: '删除成功',
							icon: 'none'
						})
						this.getCartList(true)
					} else {
						uni.showToast({
							title: '添加成功',
							icon: 'none'
						})
						this.getCartList(true)
					}
				})
			}
		}
	}
</script>

<style lang="less">
	.activityDetails {
		.swiper {
			width: 100vw;
			height: 724rpx;
		}

		.product {
			background-color: #FFFFFF;
			width: 100vw;
			height: auto;
			box-sizing: border-box;
			padding: 50rpx 30rpx;

			.content_t {
				width: 100%;
				flex-wrap: wrap;

				.content_t_l {
					width: auto;

					.price {
						color: #FF6C1D;
						font-size: 48rpx;
						font-weight: 400;

						text {
							margin-left: 8rpx;
							display: inline-block;
							font-weight: bold;
							font-size: 58rpx;
						}
					}

					.original {
						margin-left: 16rpx;
						font-size: 20rpx;
						color: #909090;
						font-weight: 500;

						.price {
							display: inline-block;
							font-size: 32rpx;
							font-weight: 400;
							color: #909090;

							text {
								display: inline-block;
								font-size: 34rpx;
								text-decoration: line-through;
							}
						}
					}

					.collage {
						width: auto;
						height: 56rpx;
						box-sizing: border-box;
						padding: 0rpx 20rpx;
						line-height: 56rpx;
						text-align: center;
						color: #FF6C1D;
						border: 1px solid #FF6C1D;
						border-radius: 10rpx;
						font-size: 24rpx;
						font-weight: 500;
						margin-left: 20rpx;

						text {
							display: inline-block;
							font-size: 32rpx;
						}
					}
				}

				.content_t_f {
					width: 35%;
					text-align: center;
					font-size: 24rpx;
					font-weight: 400;
					color: #3B3B3B;
				}
			}

			.content_b {
				width: 100%;
				margin-top: 10rpx;

				.name {
					font-weight: bold;
					font-size: 32rpx;
					color: #3B3B3B;
				}

				.introduce {
					margin-top: 10rpx;
					font-size: 28rpx;
					font-weight: 500;
					color: #666666;
				}
			}
		}

		//
		.quantity {
			width: 100vw;
			margin: 10rpx auto;
			background-color: #FFFFFF;
			box-sizing: border-box;
			padding: 30rpx;

			text {
				width: 30%;
				height: 60rpx;
				line-height: 60rpx;
				color: #666666;
				font-size: 28rpx;
				font-weight: 500;
			}

			.quantity_f {
				border: 1px solid #DEDEDE;
				border-radius: 40rpx;

				.btn {
					width: 60rpx;
					height: 60rpx;
					line-height: 60rpx;
					text-align: center;
					color: #DEDEDE;
					font-size: 40rpx;
				}

				input {
					width: 80rpx;
					height: 60rpx;
					text-align: center;
					border-left: 1px solid #DEDEDE;
					border-right: 1px solid #DEDEDE;
				}
			}

		}

		//
		.collageBox,
		.collageListPopup {
			width: 100vw;
			height: auto;
			box-sizing: border-box;
			padding: 30rpx;
			background-color: #FFFFFF;

			.content_t {
				height: 80rpx;

				.text {
					font-size: 28rpx;
					font-weight: bold;
					color: #3B3B3B;
				}

				.more {
					color: #ACACAC;
					font-weight: 500;
					font-size: 28rpx;
				}
			}

			//

			.list {
				border-top: 1px solid #F2F2F2;
				height: 120rpx;

				.list_l {
					image {
						width: 80rpx;
						height: 80rpx;
						border-radius: 50%;
					}

					.name {
						font-size: 28rpx;
						font-weight: 500;
						color: #3B3B3B;
						margin-left: 10rpx;
					}
				}

				.list_f {
					.list_f_l {
						font-size: 24rpx;
						font-weight: 500;
						text-align: center;

						.title {
							color: #3B3B3B;

							text {
								display: inline-block;
								color: #FF6C1D;
							}
						}

						.time {
							color: #717171;
						}
					}

					.collageBtn {
						width: 152rpx;
						height: 60rpx;
						line-height: 60rpx;
						text-align: center;
						background-color: #FF6C1D;
						color: #FFFFFF;
						border-radius: 10rpx;
						margin-left: 20rpx;
					}
				}
			}
		}

		//
		.userEvaluate {
			width: 100vw;
			height: auto;
			margin: 10rpx auto;
			background-color: #FFFFFF;


			.title {
				height: 90rpx;
				color: #666666;
				font-size: 28rpx;
				font-weight: bold;
				box-sizing: border-box;
				padding: 0 30rpx;

				.whole {
					font-size: 24rpx;
					font-weight: 500;
					color: #ADADAD;
				}
			}

			.list {
				width: 100%;
				height: auto;
				border-top: 1px solid #F5F5F5;
				box-sizing: border-box;
				padding: 30rpx;

				.userInfo {
					.userInfo_l {
						// image {
						// 	width: 60rpx;
						// 	height: 60rpx;
						// 	border-radius: 50%;
						// }

						.userInfo_l_r {
							margin-left: 20rpx;
							font-size: 24rpx;
							font-weight: 500;

							.name {
								padding-left: 8rpx;
							}
						}
					}

					.time {
						font-size: 20rpx;
						color: #909090;
						font-weight: 400;
					}
				}

				.evaluate {
					margin: 30rpx auto;

					.text {
						font-weight: 400;
						font-size: 24rpx;
						color: #4D4D4D;
					}

					.imageBox {
						margin: 20rpx 0rpx;
						height: 180rpx;
						overflow: hidden;
						border-radius: 8rpx;

						image {
							margin-right: 20rpx;
							width: 160rpx;
						}
					}
				}
			}

		}

		//
		.imageText {
			width: 100vw;
			height: auto;
			margin: 10rpx auto;
			background-color: #FFFFFF;

			.title {
				width: 100%;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				font-size: 28rpx;
				font-weight: bold;
				color: #767676;
			}
		}

		.cart_box {
			width: 100vw;
			height: calc(constant(safe-area-inset-bottom) + 114rpx);
			height: calc(env(safe-area-inset-bottom) + 114rpx);
			box-sizing: border-box;
			padding: 0rpx 40rpx;
			background-color: #fff;
			position: fixed;
			bottom: 0rpx;
			z-index: 99999;

			.icon {
				position: relative;

				.redDot {
					width: 30rpx;
					height: 30rpx;
					line-height: 30rpx;
					text-align: center;
					border-radius: 50%;
					font-size: 20rpx;
					background-color: red;
					color: #FFFFFF;
					position: absolute;
					top: -2rpx;
					right: -8rpx;
				}
			}

			.paymentBtn {
				margin: 0;
				width: 228rpx;
				height: 72rpx;
				line-height: 72rpx;
				text-align: center;
				border-radius: 42rpx;
				color: #fff;
				font-size: 32rpx;
				letter-spacing: 8rpx;
				background-color: #45806E;
			}
		}

		.bottomBtn {
			width: 100vw;
			height: auto;
			box-sizing: border-box;
			padding: 20rpx;
			background-color: #FFFFFF;
			position: fixed;
			left: 50%;
			bottom: constant(safe-area-inset-bottom);
			bottom: env(safe-area-inset-bottom);
			z-index: 20;
			transform: translateX(-50%);

			image {
				width: 60rpx;
				height: 60rpx;
			}

			.redDot {
				width: 30rpx;
				height: 30rpx;
				text-align: center;
				line-height: 30rpx;
				background-color: red;
				color: #FFFFFF;
				border-radius: 50%;
				position: absolute;
				right: -10rpx;
				top: -10rpx;
				z-index: 20;
			}

			.tipsBtn {
				width: 80%;
				height: 80rpx;
				margin: 0 auto;
				margin-top: 20rpx;
				line-height: 80rpx;
				text-align: center;
				background-color: #45806E;
				color: #FFFFFF;
				font-size: 32rpx;
				font-weight: bold;
				border-radius: 40rpx;

				text {
					display: inline-block;
					font-size: 28rpx;
					font-weight: 500;
					margin-left: 10rpx;
				}
			}

			.pt {
				margin: 0 auto;
			}

			.btnBox {
				width: 85%;
				height: 80rpx;
				font-size: 28rpx;
				color: #767676;
				font-weight: 500;
				margin-top: 20rpx;

				.b {
					width: 50%;
					height: 80rpx;
					text-align: center;
					line-height: 80rpx;
					border: 1px solid #45806E;
				}

				.immediately {
					border-top-left-radius: 40rpx;
					border-bottom-left-radius: 40rpx;
				}

				.join {
					background-color: #45806E;
					color: #FFFFFF;
					border-top-right-radius: 40rpx;
					border-bottom-right-radius: 40rpx;
				}

				.btn {
					width: 34%;
					height: 80rpx;
					line-height: 80rpx;
					text-align: center;
					border: 1px solid #45806E;
				}

				.purchase {
					width: 50% !important;
					background-color: #45806E;
					color: #FFFFFF;
					border-top-left-radius: 40rpx;
					border-bottom-left-radius: 40rpx;
				}

				.shopCart {
					width: 50% !important;
					border-top-right-radius: 40rpx;
					border-bottom-right-radius: 40rpx;
				}
			}
		}

		.launchPopup {
			width: 90vw;
			height: auto;
			margin: 0 auto;
			position: relative;

			.image {
				width: 214rpx;
				position: absolute;
				left: 50%;
				top: 20rpx;
				z-index: -1;
				transform: translateX(-50%);
			}

			.activity {
				width: 100%;
				height: 440rpx;
				border-radius: 10rpx;
				background-color: #FFD555;
				position: absolute;
				left: 50%;
				top: 180rpx;
				z-index: 1;
				transform: translateX(-50%);

				.background {
					width: 90%;
					height: 376rpx;
					border-radius: 10rpx;
					background-color: #FEF5E6;
					border: 1px solid #FF990F;
					position: absolute;
					left: 50%;
					top: 50%;
					transform: translate(-50%, -50%);
					text-align: center;

					.title {
						font-size: 32rpx;
						font-weight: bold;
						color: #3B3B3B;
						margin-top: 20rpx;
					}

					.text {
						font-size: 24rpx;
						font-weight: 500;
						color: #3B3B3B;
						margin-top: 20rpx;

						.time {
							display: inline-block;
							color: #FF6C1D;
						}
					}

					.popupImageBox {
						width: 90%;
						margin: 40rpx auto;
						flex-wrap: wrap;

						image {
							width: 90rpx;
							height: 90rpx;
							border-radius: 50%;
						}

						.personnel {
							width: 90rpx;
							height: 90rpx;
							text-align: center;
							line-height: 90rpx;
							border-radius: 50%;
							background-color: #F5F4F7;
							color: #A7A7A7;
						}
					}

					.btn {
						width: 208rpx;
						height: 60rpx;
						margin: 30rpx auto;
						text-align: center;
						line-height: 60rpx;
						color: #FFFFFF;
						border-radius: 10rpx;
						background: linear-gradient(165deg, #FF8408 0%, #FF7A06 53%, #FE5A00 100%);
					}
				}
			}
		}

		//
		.popup_list {
			margin-bottom: 30rpx;

			image {
				width: 140rpx;
				height: 140rpx;
			}

			.popup_list_r {
				width: 75%;
				box-sizing: border-box;
				padding-right: 40rpx;

				.list_r_t {
					.name {
						font-size: 36rpx;
						color: #4B4B4B;
						font-weight: 500;
					}

					.time {
						font-size: 22rpx;
						color: #555555;
						font-weight: 300;
					}
				}

				.list_r_b {
					margin-top: 40rpx;

					.popup_price {
						color: #FF6C1D;
						font-size: 32rpx;

						text {
							font-size: 40rpx;
							display: inline-block;
						}
					}

					.popup_quantity {
						.text {
							font-size: 40rpx;
						}

						.quantityNum {
							width: 100rpx;
							height: 40rpx;
							line-height: 40rpx;
							text-align: center;
							background-color: #F2F2F2;
							font-size: 36rpx;
							margin: 0rpx 20rpx;
						}
					}
				}

				// 
			}
		}
	}



	.popup {
		text-align: center;

		image {
			width: 80rpx;
			height: 80rpx;
			margin-top: 120rpx;
		}

		.text {
			width: 100%;
			font-size: 32rpx;
			font-weight: 500;
			color: #4B4B4B;
			margin-top: 40rpx;
		}

		.btn {
			width: 228rpx;
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			background-color: #45806E;
			color: #FFFFFF;
			border-radius: 40rpx;
			margin: 80rpx auto;
		}


	}
</style>
